const state = {
  selectValue: "", // 选择的课程
  selectedId: "", // 选择课程的ID
  paperCount: 0, // 试卷数量
  breadcrumbs: [{ name: "全部课程", id: null }], // 添加 breadcrumbs 状态
};

const mutations = {
  SET_SELECT_VALUE: (state, value) => {
    state.selectValue = value;
  },
  SET_SELECTED_ID: (state, id) => {
    state.selectedId = id;
  },
  SET_PAPER_COUNT: (state, count) => {
    state.paperCount = count;
  },
  SET_BREADCRUMBS: (state, breadcrumbs) => {
    state.breadcrumbs = breadcrumbs;
  },
};

const actions = {
  // 设置选择的课程
  setSelectValue({ commit }, value) {
    commit("SET_SELECT_VALUE", value);
  },
  // 设置选择的课程ID
  setSelectedId({ commit }, id) {
    commit("SET_SELECTED_ID", id);
  },
  // 设置试卷数量
  setPaperCount({ commit }, count) {
    commit("SET_PAPER_COUNT", count);
  },
  // 设置面包屑
  setBreadcrumbs({ commit }, breadcrumbs) {
    commit("SET_BREADCRUMBS", breadcrumbs);
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
